﻿<Window x:Class="LogViewer.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:LogViewer"
    Title="LogViewer" Height="800" Width="700"
    SizeToContent="WidthAndHeight"
    ResizeMode="CanResizeWithGrip" 
    AllowDrop="True"
    Closing="Window_Closing">
    <DockPanel Background="{DynamicResource Brush_HeaderBackground}">
        <Grid DockPanel.Dock="Top">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Menu Grid.Column="0" Name="menu1" Height="22" HorizontalAlignment="Stretch">
                    <MenuItem Header="File" >
                        <MenuItem Header="Open" Click="MenuFileOpen_Click" />
                        <Separator BorderThickness="1" />
                        <local:RecentFileList x:Name="RecentFileList"/>
                        <Separator BorderThickness="1" />
                        <MenuItem Header="Exit" Click="MenuFileExit_Click"/>
                    </MenuItem>
                    <MenuItem Header="Refresh" Click="MenuRefresh_Click"  />
                    <MenuItem Header="Filter" Click="MenuFilter_Click" />
                    <MenuItem Header="About" Click="MenuAbout_Click"  />
                </Menu>
                <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Background="{DynamicResource Brush_HeaderBackground}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="10"/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                    <StackPanel Grid.Column="1" Orientation="Horizontal">
                        <Image x:Name="imageError" Height="16" Width="16" Visibility="Hidden" VerticalAlignment="Center"/>
                        <Label x:Name="labelErrorCount" Visibility="Hidden" VerticalAlignment="Center" />
                    </StackPanel>
                    <StackPanel Grid.Column="2" Orientation="Horizontal">
                        <Image x:Name="imageInfo" Height="16" Width="16" Visibility="Hidden" VerticalAlignment="Center"/>
                        <Label x:Name="labelInfoCount" Visibility="Hidden" VerticalAlignment="Center"/>
                    </StackPanel>
                    <StackPanel Grid.Column="3" Orientation="Horizontal">
                        <Image x:Name="imageWarn" Height="16" Width="16" Visibility="Hidden" VerticalAlignment="Center"/>
                        <Label x:Name="labelWarnCount" Visibility="Hidden" VerticalAlignment="Center"/>
                    </StackPanel>
                    <StackPanel Grid.Column="4" Orientation="Horizontal">
                        <Image x:Name="imageDebug" Height="16" Width="16" Visibility="Hidden"/>
                        <Label x:Name="labelDebugCount" Visibility="Hidden" VerticalAlignment="Center"/>
                    </StackPanel>
                </StackPanel>
            </Grid>
            <Grid Grid.Row="1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                </Grid>
                <StackPanel Grid.Column="0" Orientation="Horizontal">
                    <Label Foreground="#FFC3C9E9"
                           FontWeight="Normal"
                           FontSize="16"
                           FontFamily="Calibri"
                           Content="Path:"/>
                    <TextBox Name="textboxFileName"
                           Foreground="Orange"
                           FontWeight="Normal"
                           FontSize="16"
                           FontFamily="Calibri"
                           HorizontalAlignment="Stretch"
                           Background="Transparent"                       
                           BorderThickness="0"
                           Margin="2,2,2,2" Width="400" />
                </StackPanel>
                <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button Content="重置" Click="buttonAgain_Click"></Button>
                    <Image Name="image2" Width="16" Height="16" Margin="2" Source="/LogViewer;component/Resources/Images/find.png" VerticalAlignment="Center"/>
                    <Button Height="23"   Width="27" Click="buttonFindNextError_Click" Cursor="Hand" VerticalAlignment="Center">
                        <Button.Template>
                            <ControlTemplate>
                                <Image Width="16" Height="16" ToolTip="Find Next" Source="/LogViewer;component/Resources/Images/arrow_right.png" />
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                    <Label Name="label3" Foreground="Red" Content="Find ERROR:"   VerticalAlignment="Center"/>
                    <TextBox Height="20" Name="textBoxFind" Width="120" VerticalAlignment="Center" AcceptsReturn="False" KeyDown="textBoxFind_KeyDown" />
                    <TextBox Height="20" Name="txt2" Width="120" VerticalAlignment="Center" AcceptsReturn="False" KeyDown="textBoxFind_KeyDown" />
                    <TextBox Height="20" Name="txt3" Width="120" VerticalAlignment="Center" AcceptsReturn="False" KeyDown="textBoxFind_KeyDown" />
                    <TextBox Height="20" Name="txt4" Width="120" VerticalAlignment="Center" AcceptsReturn="False" KeyDown="textBoxFind_KeyDown" />
                    <TextBox Height="20" Name="txt5" Width="120" VerticalAlignment="Center" AcceptsReturn="False" KeyDown="textBoxFind_KeyDown" />
                    <Button Height="23" Name="buttonFindNext" Width="27" Click="buttonFindNext_Click" Cursor="Hand" VerticalAlignment="Center">
                        <Button.Template>
                            <ControlTemplate>
                                <Image Width="16" Height="16" ToolTip="Find Next" Source="/LogViewer;component/Resources/Images/arrow_right.png" />
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                    <Button Height="23" Name="buttonFindPrevious" Width="23" Click="buttonFindPrevious_Click" Cursor="Hand" VerticalAlignment="Center">
                        <Button.Template>
                            <ControlTemplate>
                                <Image Width="16" Height="16" ToolTip="Find Previous" Source="/LogViewer;component/Resources/Images/arrow_left.png" />
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                </StackPanel>
                
            </Grid>
        </Grid>        
        <StatusBar Height="23" DockPanel.Dock="Bottom" Foreground="#FFE9EEF0" Background="{DynamicResource Brush_StatusBarBackground}">
            <StatusBarItem Content="Ready"/>
        </StatusBar>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="300"/>
                <RowDefinition Height="130" />
                <RowDefinition Height="1*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <GridSplitter Name="gridSplitter1" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Grid.Row="0" Height="4">
                <GridSplitter.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="LightGray" Offset="0"/>
                        <GradientStop Color="DarkGray" Offset="1"/>
                    </LinearGradientBrush>
                </GridSplitter.Background>
            </GridSplitter>
            <!-- List View -->
            <Border BorderThickness="4,4,4,4" Margin="0,0,0,10">
                <ListView Name="listView1" 
                      Grid.Row="0" 
                      ItemsSource= "{Binding ElementName=Window1, Path=Entries}" 
                      AllowDrop="True"
                      SelectionChanged="listView1_SelectionChanged" 
                      Drop="listView1_Drop">
                    <ListView.ItemContainerStyle>
                        <Style TargetType="{x:Type ListViewItem}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Level}" Value="ERROR">
                                    <Setter Property="Background" Value="LightGray"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Level}" Value="INFO">
                                    <Setter Property="Background" Value="LightGreen"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Level}" Value="DEBUG">
                                    <Setter Property="Background" Value="LightGreen"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Level}" Value="WARN">
                                    <Setter Property="Background" Value="White"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Level}" Value="FATAL">
                                    <Setter Property="Background" Value="Red"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Level}" Value="COMPRESSION">
                                    <Setter Property="Background" Value="Gainsboro" />
                                </DataTrigger>
                            </Style.Triggers>
                            <Setter Property="Height" Value="20"/>
                        </Style>
                    </ListView.ItemContainerStyle>
                    <ListView.View>
                        <GridView x:Name="GridView1">
                            <GridViewColumn Header="Item" DisplayMemberBinding="{Binding Item}"  />
                            <GridViewColumn Header="TimeStamp" DisplayMemberBinding="{Binding TimeStamp}"/>
                            <GridViewColumn Header="">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Image Source="{Binding Image}" Width="16" Height="16" VerticalAlignment="Top" HorizontalAlignment="Left"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Level" DisplayMemberBinding="{Binding Level}"/>
                            <GridViewColumn Header="Thread" DisplayMemberBinding="{Binding Thread}"/>
                            <GridViewColumn Header="Message" DisplayMemberBinding="{Binding Message}" Width="250" />
                            <GridViewColumn Header="MachineName" DisplayMemberBinding="{Binding MachineName}"/>
                            <GridViewColumn Header="HostName" DisplayMemberBinding="{Binding HostName}"/>
                            <GridViewColumn Header="UserName" DisplayMemberBinding="{Binding UserName}"/>
                            <GridViewColumn Header="App" DisplayMemberBinding="{Binding App}"/>
                            <GridViewColumn Header="Class" DisplayMemberBinding="{Binding Class}"/>
                        </GridView>
                    </ListView.View>
                </ListView>
            </Border>
            <!-- Data Fields and Tab Control  -->
            <Grid Grid.Row="1" Margin="15,0,15,10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="10"/>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="10"/>
                </Grid.RowDefinitions>

                <!-- Row 1-->
                <Image Name="image1" Width="16" Height="16" Grid.Column="0" Grid.Row="1" />
                <TextBox Name="textBoxLevel" Height="23" Grid.Column="1" Grid.Row="1" />
                <Label Name="label1" Height="28" Grid.Column="2" Grid.Row="1">Time Stamp</Label>
                <TextBox Name="textBoxTimeStamp" Height="23" Grid.Column="3" Grid.Row="1" />
                <Label Name="label2" Height="28" Grid.Column="4" Grid.Row="1">Machine Name</Label>
                <TextBox Name="textBoxMachineName" Height="23" Grid.Column="5" Grid.Row="1" />
                <Label Name="labelThread" Grid.Column="6" Grid.Row="1">Thread</Label>
                <TextBox Name="textBoxThread" Grid.Column="7" Grid.Row="1"/>

                <!-- Row 2 -->
                <Label Name="labelItem" Height="28" Grid.Column="0" Grid.Row="2">Item</Label>
                <TextBox Name="textBoxItem" Height="23" Grid.Column="1" Grid.Row="2" />
                <Label Name="label4" Height="28" Grid.Column="2" Grid.Row="2">Host Name</Label>
                <TextBox Name="textBoxHostName" Height="23" Grid.Column="3" Grid.Row="2"/>
                <Label Name="label5" Height="28" Grid.Column="4" Grid.Row="2">User Name</Label>
                <TextBox Name="textBoxUserName" Height="23" Grid.Column="5" Grid.Row="2"/>
                <Label Name="label6" Height="28" Grid.Column="6" Grid.Row="2">App</Label>
                <TextBox Name="textBoxApp" Height="23" Grid.Column="7" Grid.Row="2"/>

                <!-- Row 3-->
                <Label Name="label7" Height="28" Grid.Column="0" Grid.Row="3">Class</Label>
                <TextBox Name="textBoxClass" Height="23" Grid.Column="1" Grid.Row="3"/>
                <Label Name="label8" Height="28" Grid.Column="2" Grid.Row="3">Method</Label>
                <TextBox Name="textBoxMethod" Height="23" Grid.Column="3" Grid.Row="3"/>
                <Label Name="label9" Height="28" Grid.Column="4" Grid.Row="3">Line</Label>
                <TextBox Name="textBoxLine" Height="23" Grid.Column="5" Grid.Row="3"/>

                <!-- Row 4-->
                <Label Name="labelFile" Height="23" Grid.Column="0" Grid.Row="4">File</Label>
                <TextBox Name="textBoxfile" Height="28" Grid.Column="1" Grid.ColumnSpan="7" Grid.Row="4"/>

            </Grid>
            <TabControl Name="tabControl1" Grid.Row="2" Grid.Column="0" Margin="15,0,15,10" >
                <TabItem Header="Message">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="1*"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <ScrollViewer   VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" >  
                            <TextBox Name="textBoxMessage" MaxWidth="600" TextWrapping="Wrap" BorderThickness="0" />
                        
                    </ScrollViewer>
                    </Grid>
                </TabItem>
                <TabItem Header="Throwable">
                    <TextBox Name="textBoxThrowable" TextWrapping="Wrap" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" BorderThickness="0"/>
                </TabItem>
            </TabControl>
        </Grid>
    </DockPanel>
</Window>
